apiVersion: v1
kind: Namespace
metadata:
  name: fib
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: fib
  namespace: fib
spec:
  selector:
    matchLabels:
      app: "fib"
  template:
    metadata:
      labels:
        app: "fib"
    spec:
      containers:
        - name: "fib"
          image: {{ fib_image }}
          imagePullPolicy: "Always"
          resources:
            requests:
              cpu: "1000m"
              memory: "2048Mi"
            limits:
              cpu: "2000m"
              memory: "2048Mi"
          ports:
            - containerPort: {{ port }}
              name: "web"
              protocol: "TCP"
      nodeSelector:
        {%- for node_selector in node_selectors %}
        {{node_selector}}
        {%- endfor %}
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: "fib"
  namespace: "fib"
spec:
  scaleTargetRef:
    apiVersion: "apps/v1"
    kind: "Deployment"
    name: "fib"
  minReplicas: 5
  maxReplicas: 250
  metrics:
    - type: "Resource"
      resource:
        name: "cpu"
        target:
          type: "Utilization"
          averageUtilization: 70
  behavior:
    scaleDown:
      stabilizationWindowSeconds: 60
      policies:
        - periodSeconds: 15
          type: "Percent"
          value: 100
      selectPolicy: "Min"
    scaleUp:
      stabilizationWindowSeconds: 0
      policies:
        - periodSeconds: 15
          type: "Percent"
          value: 100
        - periodSeconds: 15
          type: "Pods"
          value: 1000
      selectPolicy: "Max"
